home *** CD-ROM | disk | FTP | other *** search
- Path: brahms.tfi.be!usenet
- From: Tasmaniac@unicall.be (Tasmaniac)
- Newsgroups: alt.msdos.programmer,comp.lang.c
- Subject: Re: Pascal program works but not C program!
- Date: Sun, 07 Jan 1996 18:29:49 GMT
- Organization: ACiD
- Message-ID: <4cp3vc$8nh@brahms.tfi.be>
- References: <4cdpr2$psi@lugb.latrobe.edu.au> <Pine.SV4.3.91-heb-2.04.960104114930.16292A-100000@cs.technion.ac.il>
- NNTP-Posting-Host: 193.210.154.87
- X-Newsreader: Forte Free Agent 1.0.82
-
- >> Why does the Pascal version of this program behave exactly as expected while the
- >> C++ version does not?
- let's have a look...
-
- >> while ((y<=height) && (!empty(posptr->next)))
- >> {
- >> gotoxy(1,y);
- >> strcpy(line_,posptr->line);
- >> line__=&(line_[stringpos]);
- >> strncpy(line,line__,width-1);
- This isn't valid, you can't 'strncpy' single characters to a string.
- It SHOULD give you a warning on that.
-
- >> strcat(line,null);
- > ^---------------This is a problem!!!!!!!!!
- No, it was probably already wrong on the previous line.
-
- >> void main(int argc,char *argv[])
- > ^-----------------------------This one too, but not too serious
- why is this a problem ?
-
- >Another problem, not as serious as the previous one, although this is not
- >the reason the C++ version might not work; main() should be defined
- >returning int, not void.
- It's 100% legal to declare main as any of the following
-
- void main (void)
- int main (void)
- void main (int argc, char *argv[])
- int main (int argc, char *argv[])
- void main (int argc, char **argv)
- int main (int argc, char **argv)
- void main (int argc, char *argv[], char *envp[])
- int main (int argc, char *argv[], char *envp[])
- void main (int argc, char *argv[], char **envp)
- int main (int argc, char *argv[], char **envp)
- void main (int argc, char **argv, char *envp[])
- int main (int argc, char **argv, char *envp[])
- void main (int argc, char **argv, char **envp)
- int main (int argc, char **argv, char **envp)
-
- erhm.. that should be it, I may have missed one...
-
-
-
-